<?php
require_once(OC::$SERVERROOT . "/apps/jobposition/lib/helper.php");
require_once(OC::$SERVERROOT . "/apps/resumes/lib/helper.php");

if(!OC_User::isLoggedIn()) {
   echo '您需要先登录';
   exit();
}

OCP\JSON::callCheck();

$companyid = PFactory::getMasterUser()->id;

$url = JRequest::getString('url', '');
$type = JRequest::getString('type', 'reports');

$folderList = PJobpositionHelper::getCustomFolderList($companyid, 0, $type, false);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tbody>
      <?php
      if (empty($folderList)) {
         echo '<tr><td colspan=2>暂无职位组合</td></tr>';
      } else {
      ?>
      <tr>
      <?php
         $n=count($folderList);
         for ($i=0; $i < $n; $i++) {
            $folder = $folderList[$i];
            if ($i != 0 && ($i%2) == 0) {
               echo '</tr><tr>';
            }
            $href = PResumesHelper::getSearchItemHref($url, 'fid', $folder->folder_id)[0];
            echo '<td width="50%" data-fid="' . $folder->folder_id . '" data-fname="' . $folder->folder_name . '"><a class="selectitem" href="javascript:;">' . $folder->folder_name . '</a><span class="edit"></span><span class="delete"></span></td>';
         }
         $filledNum = 2 - ($n%2);
         if ($filledNum < 2) {
            for ($i=0; $i < $filledNum; $i++) {
               echo '<td width="50%"></td>';
            }
         }
      }
      ?>
      </tr>
   </tbody>
</table>